Skip to content

fix: FilesViewModel - WPB-24805#4590

Merged
WilhelmOks merged 98 commits into
developfrom
improvement/WPB-24805-FilesViewModel-2
May 18, 2026
Merged

fix: FilesViewModel - WPB-24805#4590
WilhelmOks merged 98 commits into
developfrom
improvement/WPB-24805-FilesViewModel-2

Conversation

@WilhelmOks
Copy link
Copy Markdown
Contributor

@WilhelmOks WilhelmOks commented Apr 20, 2026

TaskWPB-24805 [iOS] improve FilesViewModel of WireDrive

Issue

The swift file FilesViewModel is almost 1k loc long, is shared by multiple Views and has accumulated a lot of code for different kinds of functionality.
This makes it hard to read and maintain it.

Solution

Many different kinds of refactoring were implemented resulting in the FilesViewModel.swift file being about 50% smaller:

  • extracted FilesViewItem into a separate file
  • refactored SheetNavigation to use Model data instead of SwiftUI Views as payload, eliminating the need for import SwiftUI in ViewModel code
  • refactored sub-views and sheets to consistently use callbacks instead of Combine bindings to notify the parent view about specific events
  • unified creation of sub-views or sheets to only create the ViewModels rather than SwiftUI Views
  • extracted all functions which create ViewModels into the extension FilesViewModel+make_ViewModels.swift
  • extracted the big UseCases nested struct into the extension FilesViewModel+UseCases.swift
  • extracted the big function for loading offline files into LoadOfflineAvailableFilesUIAction
  • extracted logic related to loading paginated lists of (file) items into the components IncrementalListLoader and FilesListLoader
  • moved and grouped all of the remaining functions using // MARK: label comments

Testing

The logic should be exactly the same after the refactoring.

  • Go to the files list, via the Drive tab or the Shared Drive of a conversation
  • Check if the list is loaded correctly and the pagination is right
  • Check offline mode and if the list of offline available files is loaded correctly
  • Check deleting and restoring files via recycle bin

jullianm and others added 30 commits March 27, 2026 10:33
… Publisher with the need for manually setting up a sink
…WPB-23967-make-files-available-offline-ui-bl

# Conflicts:
#	WireMessaging/Sources/WireMessagingUI/WireDrive/Components/Files/Item/FilesItemViewModel.swift
…WPB-23967-make-files-available-offline-ui-bl

# Conflicts:
#	WireMessaging/Sources/WireMessagingUI/WireDrive/Components/Files/FilesContentView.swift
#	WireMessaging/Sources/WireMessagingUI/WireDrive/Components/Files/Item/FilesItemViewModel.swift
…WPB-23967-make-files-available-offline-ui-bl
…WPB-23967-make-files-available-offline-ui-bl

# Conflicts:
#	WireMessaging/Sources/WireMessagingUI/WireDrive/Components/Files/Item/FilesItemViewModel.swift
#	WireMessaging/Sources/WireMessagingUI/WireDrive/Components/Files/Item/FilesViewItemView.swift
@WilhelmOks WilhelmOks marked this pull request as ready for review May 5, 2026 14:41
@WilhelmOks WilhelmOks requested a review from OlivellaO May 5, 2026 14:42
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

Test Results

303 tests   303 ✅  1m 10s ⏱️
 60 suites    0 💤
  1 files      0 ❌

Results for commit ddb163d.

♻️ This comment has been updated with latest results.

Summary: workflow run #26039042254
Allure report (download zip): html-report-30056-improvement_WPB-24805-FilesViewModel-2

Copy link
Copy Markdown
Contributor

@OlivellaO OlivellaO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Contributor

@jullianm jullianm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice clean up of the view model, I left a couple of feedbacks/issues specifically related to the loaders components.

@datadog-wireapp
Copy link
Copy Markdown

datadog-wireapp Bot commented May 11, 2026

Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: ddb163d | Docs | Give us feedback!

Copy link
Copy Markdown
Contributor

@jullianm jullianm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

@WilhelmOks WilhelmOks enabled auto-merge May 18, 2026 14:13
@sonarqubecloud
Copy link
Copy Markdown

@WilhelmOks WilhelmOks added this pull request to the merge queue May 18, 2026
Merged via the queue into develop with commit c834a8a May 18, 2026
13 checks passed
@WilhelmOks WilhelmOks deleted the improvement/WPB-24805-FilesViewModel-2 branch May 18, 2026 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants